<openerp>
<data>
	
	<!-- base structure of product.template, common with product.product -->
    <record id="searching_product_template_form_view" model="ir.ui.view">
        <field name="name">searching.product.template.common.form</field>
        <field name="model">product.template</field>
        <field name="mode">primary</field>
        <field eval="8" name="priority"/>
        <field name="arch" type="xml">
            <form string="Product" create="0" edit="0" delete="false">
                <field name="is_product_variant" invisible="1"/>
                <field name='product_variant_count' invisible='1'/>
                <sheet>
                    <field name="id" invisible="True"/>
                    <div class="oe_right oe_button_box" style="width: 300px;" name="buttons"></div>
                    <div class="oe_left" style="width: 500px;">
                        <field name="image_medium" widget="image" class="oe_avatar oe_left"/>
                        <div class="oe_title" style="width: 390px;">
                            <label class="oe_edit_only" for="name" string="Product Name"/>
                            <h1><field name="name" class="oe_inline"/></h1>
                        </div>
                        <div class="oe_left" name="options" groups="base.group_user">
                            <div>
                                <field name="sale_ok"/>
                                <label for="sale_ok"/>
                            </div>
                            <div>
								<field name="purchase_ok" modifiers="{}"/>
								<label for="purchase_ok"/>
							</div>
                    	</div>
                    </div>
                    <notebook>
                        <page string="Information">
                            <group colspan="4">
                                <group>
                                    <field name="type"/>
                                    <field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="product.group_uom"/>
                                    <field name="list_price"/>
                                </group>
                                <group>
                                    <field name="active"/>
                                    <field name="ean13" attrs="{'invisible': [('product_variant_count', '>', 1)]}"/>
                					<field name="default_code" attrs="{'invisible': [('product_variant_count', '>', 1)]}"/>
                                </group>
                            </group>
                            <group colspan="4">
                                <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                            </group>
                            <field name="description" placeholder="describe the product characteristics..."/>
                        </page>
                        <page string="Procurements" groups="base.group_user">
                            <group name="procurement">
                                <group name="general">
                                	<field name="cost_method" groups="stock_account.group_inventory_valuation" attrs="{'invisible': [('type','=','service')]}"/>
				                    <label string="Cost Price" for="standard_price" align="1.0" groups="base.group_user"/>
				                    <div groups="base.group_user">
				                        <field name="standard_price" attrs="{'readonly':['&amp;', ('valuation','=','real_time'), ('cost_method', 'in', ['standard', 'average'])]}" nolabel="1"/>
				                    </div>
                                </group>
                                <group name="procurement_uom" groups="product.group_uom" string="Purchase">
                                    <field name="uom_po_id"/>
                                </group>
                            </group>
                            <separator string="Suppliers"/>
                            <field name="seller_ids"/>
                            <separator string="Description for Suppliers"/>
                            <field name="description_purchase" placeholder="This note will be displayed on requests for quotation..."/>
                        </page>
                        <page string="Inventory">
                            <group name="inventory">
                                 <group name="status" string="Status">
                                    <field name="state"/>
                                    <field name="product_manager"/>
                                </group>
                                <group name="weight" string="Weights" attrs="{'invisible':[('type','=','service')]}">
                                    <field digits="(14, 3)" name="volume"/>
                                    <field digits="(14, 3)" name="weight"/>
                                    <field digits="(14, 3)" name="weight_net"/>
                                </group>
                            </group>
                            <group name="packaging" string="Packaging" attrs="{'invisible':[('type','=','service')]}" groups="product.group_stock_packaging" colspan="4">
                                <field name="packaging_ids" string="Configurations" context="{'tree_view_ref':'product.product_packaging_tree_view_product', 'form_view_ref': 'product.product_packaging_form_view_without_product'}"/>
                            </group>
                        </page>
                        <page string="Sales" attrs="{'invisible':[('sale_ok','=',False)]}" name="sales">
                            <group name="sale">
                                <group name="sale_condition" string="Sale Conditions" colspan="3">
                                    <label for="warranty"/>
                                    <div>
                                        <field name="warranty" class="oe_inline"/> months
                                    </div>
                                </group>
                                <group groups="product.group_uos" string="Unit of Measure">
                                    <field name="uos_id"/>
                                    <field name="uos_coeff"/>
                                    <field name="mes_type"/>
                                </group>
                            </group>
                            <group name="website_and_pos" col="2">
                            </group>
                            <separator string="Description for Quotations"/>
                            <field name="description_sale" placeholder="note to be displayed on quotations..."/>
                        </page>
                        <page name="variants" string="Variants">
	                      <p class="oe_grey">
	                          <strong>Warning</strong>: adding or deleting attributes
	                          will delete and recreate existing variants and lead
	                          to the loss of their possible customizations.
	                      </p>
	                      <field name="attribute_line_ids" widget="one2many_list" context="{'show_attribute': False}">
	                          <tree string="Variants" editable="bottom">
	                              <field name="attribute_id"/>
	                              <field name="value_ids" widget="many2many_tags" options="{'no_create_edit': True}" domain="[('attribute_id', '=', attribute_id)]" context="{'default_attribute_id': attribute_id}"/>
	                          </tree>
	                      </field>
	                  	</page>
	                  	<page string="Accounting">
							<group>
								<label for="categ_id" string="Internal Category"/>
								<div>
									<field name="categ_id" colspan="3" nolabel="1" modifiers="{'required': true}"/>
								</div>
							</group>
							<group attrs="{'invisible': [('type','=','service')]}" modifiers="{'invisible': [['type', '=', 'service']]}">
								<separator string="Inventory Valuation" colspan="4"/>
								<group colspan="2" col="2">
									<field name="valuation" attrs="{'readonly':[('type', '=', 'service')]}" modifiers="{'readonly': [['type', '=', 'service']], 'required': true}"/>
								</group>
								<group colspan="2" col="2">
									<field name="property_stock_account_input" attrs="{'invisible':[('valuation', '!=', 'real_time')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" modifiers="{'invisible': [['valuation', '!=', 'real_time']]}"/>
									<field name="property_stock_account_output" attrs="{'invisible':[('valuation', '!=', 'real_time')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" modifiers="{'invisible': [['valuation', '!=', 'real_time']]}"/>
								</group>
							</group>
							<newline/>
							<group name="properties">
								<group>
									<field name="property_account_income" domain="[('type','=','other')]" modifiers="{}"/>
									<field name="taxes_id" colspan="2" widget="many2many_tags" modifiers="{}"/>
								</group>
								<group>
									<field name="property_account_expense" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" modifiers="{'readonly': [['purchase_ok', '=', 0]]}"/>
									<field name="supplier_taxes_id" colspan="2" widget="many2many_tags" attrs="{'readonly':[('purchase_ok','=',0)]}" modifiers="{'readonly': [['purchase_ok', '=', 0]]}"/>
								</group>
							</group>
						</page>
                    </notebook>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
            </form>
        </field>
	 </record>
	
	 <record id="searching_product_template_tree" model="ir.ui.view">
	    <field name="name">searching.product.template.tree</field>
	    <field name="model">product.template</field>
	    <field name="arch" type="xml">
         	<tree string="Product" create="0" edit="0" delete="false" colors="red:virtual_available&lt;0;blue:virtual_available&gt;=0 and state in ('draft', 'end', 'obsolete');black:virtual_available&gt;=0 and state not in ('draft', 'end', 'obsolete')">
				<field name="name" modifiers="{'required': true}"/>
				<field name="categ_id" modifiers="{'required': true}"/>
				<field name="type" modifiers="{'required': true}"/>
				<field name="state" modifiers="{}"/>
				<field name="uom_id" invisible="1" modifiers="{'required': true, 'tree_invisible': true}"/>
				<field name="qty_available" modifiers="{'readonly': true}"/>
				<field name="virtual_available" modifiers="{'readonly': true}"/>
			</tree>
		</field>
    </record>
	
	<record id="searching_product_template_search_view" model="ir.ui.view">
        <field name="name">searching.product.template.search</field>
        <field name="model">product.template</field>
        <field name="arch" type="xml">
            <search string="Product">
                <field name="name" string="Product" filter_domain="['|',('default_code','ilike',self),('name','ilike',self)]"/>
                <filter string="Services" icon="terp-accessories-archiver" domain="[('type','=','service')]"/>
                <filter string="Consumable" name="consumable" icon="terp-accessories-archiver" domain="[('type','=','consu')]" help="Consumable products"/>
                <separator/>
                <filter string="Can be Sold" name="filter_to_sell" icon="terp-accessories-archiver-minus" domain="[('sale_ok','=',1)]"/>
                <field name="categ_id" filter_domain="[('categ_id', 'child_of', self)]"/>
                <field string="Product Variant" name="product_variant_ids" filter_domain="['|', ('product_variant_ids.name','ilike',self), ('product_variant_ids.attribute_value_ids.name','ilike',self)]"/>
                <field name="company_id"/>
                <field name="pricelist_id" widget="selection" context="{'pricelist': self}" filter_domain="[]" groups="product.group_sale_pricelist"/> <!-- Keep widget=selection on this field to pass numeric `self` value, which is not the case for regular m2o widgets! -->
                <group  expand='0' string='Group by...'>
                   <filter string='Category' domain="[]" context="{'group_by' : 'categ_id'}"/>
                   <filter string='Default Unit of Measure' icon="terp-mrp" domain="[]" context="{'group_by' : 'uom_id'}"/>
                   <filter string='Type' icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'type'}"/>
                </group>
                <field name="product_variant_ids" position="before">
                    <separator/>
                    <filter name="real_stock_available" string="Available Products" domain="[('qty_available','&gt;',0)]"/>
                    <filter name="virtual_stock_available" string="Forecast Available Products" domain="[('virtual_available','&gt;',0)]"/>
                    <filter name="real_stock_exhausted" string="Exhausted Stock" domain="[('qty_available','&lt;=',0)]"/>
                    <filter name="virtual_stock_exhausted" string="Forecast Exhausted Stock" domain="[('virtual_available','&lt;=',0)]"/>
                    <filter name="real_stock_negative" string="Negative Stock" domain="[('qty_available','&lt;',0)]"/>
                    <filter name="virtual_stock_negative" string="Forecast Negative Stock" domain="[('virtual_available','&lt;',0)]"/>
                </field>
                <filter name="consumable" position="before">
                   <filter string="Products" icon="terp-accessories-archiver" domain="[('type','=','product')]" help="Stockable products"/>
                </filter>
            </search>
        </field>
    </record>
	
	<!-- Product Variants -->
	<record id="searching_product_product_tree_view" model="ir.ui.view">
        <field name="name">searching.product.product.tree</field>
        <field name="model">product.product</field>
        <field eval="7" name="priority"/>
        <field name="arch" type="xml">
            <tree string="Product Variants" create="0" edit="0" delete="false">
                <field name="default_code"/>
                <field name="name"/>
                <field name="attribute_value_ids" widget="many2many_tags"/>
                <field name="lst_price"/>
                <field name="price" invisible="not context.get('pricelist',False)"/>
                <field name="uom_id"/>
                <field name="ean13"/>
                <field name="state" invisible="1"/>
                <field name="product_tmpl_id" invisible="1"/>
            </tree>
        </field>
    </record>
	
	<record id="searching_product_normal_form_view" model="ir.ui.view">
        <field name="name">searching.product.product.form</field>
        <field name="model">product.product</field>
        <field name="mode">primary</field>
        <field eval="7" name="priority"/>
        <field name="inherit_id" ref="searching_product_template_form_view"/>
        <field name="arch" type="xml">
            <form create="0" edit="0" delete="false" position="attributes">
                <attribute name="string">Product Variant</attribute>
            </form>
            <field name="active" position="after">
                <field name="ean13"/>
                <field name="default_code"/>
            </field>
            <field name="list_price" position="attributes">
               <attribute name="name">lst_price</attribute>
            </field>
            <field name="name" position="replace">
                <field name="name" attrs="{'invisible': [('id', '!=', False)]}"/>
                <field name="product_tmpl_id" class="oe_inline" readonly="1" attrs="{'invisible': [('id', '=', False)], 'required': [('id', '!=', False)]}"/>
            </field>
            <xpath expr="//div[@class='oe_title']" position="inside">
                <field name="attribute_value_ids" widget="many2many_tags"/>
            </xpath>
            <page name="variants" position="replace">
              	<page name="variants" string="Variants" invisible="1"/>
           	</page>
        </field>
    </record>
	
	<record id="searching_product_kanban_view" model="ir.ui.view">
        <field name="name">Product Kanban</field>
        <field name="model">product.product</field>
        <field name="arch" type="xml">
            <kanban create="0" edit="0">
                <field name="image_small"/>
                <field name="lst_price"/>
                <templates>
                    <t t-name="kanban-box">
                        <div class="oe_kanban_vignette oe_semantic_html_override">
                            <a type="open"><img t-att-src="kanban_image('product.product', 'image_small', record.id.value)" class="oe_kanban_image"/></a>
                            <div class="oe_kanban_details">
                                <h4>
                                    <a type="open">
                                        <field name="name"/>
                                        <field name="attribute_value_ids"/>
                                    </a>
                                </h4>
                                <div name="tags"/>
                                <ul>
                                    <li>Price: <field name="lst_price"></field></li>
                                </ul>
                            </div>
                        </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>
	
	<record id="searching_product_search_form_view" model="ir.ui.view">
            <field name="name">searching.product.product.search</field>
            <field name="model">product.product</field>
            <field name="mode">primary</field>
            <field name="inherit_id" ref="searching_product_template_search_view"/>
            <field name="arch" type="xml">
                <field name="product_variant_ids" position="replace">
                    <field name="attribute_value_ids"/>
                </field>
                <field name="name" position="after">
                   <field name="product_tmpl_id" string="Product Template"/>
                </field>
                <xpath expr="//group[@string='Group by...']" position="inside">
                    <filter string='Product Template' name="template_id" domain="[]" context="{'group_by' : 'product_tmpl_id'}"/>
                </xpath>
            </field>
        </record>
	
	<record id="searching_product_variant_action" model="ir.actions.act_window">
        <field name="name">Product Variants</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">product.product</field>
        <field name="view_mode">tree,form,kanban</field>
        <field name="view_type">form</field>
        <field name="context">{'search_default_product_tmpl_id': [active_id], 'default_product_tmpl_id': active_id}</field>
        <field name="search_view_id" ref="searching_product_search_form_view"/>
        <field name="view_id" eval="False"/> <!-- Force empty -->
        <field name="domain" eval="False"/> <!-- Force empty -->
        <field name="help" type="html">
          <p class="oe_view_nocontent_create">
            Click to define a new product.
          </p><p>
            You must define a product for everything you buy or sell,
            whether it's a physical product, a consumable or service.
          </p>
        </field>
    </record>
	
	<record id="action_searching_product_product_tree_view" model="ir.actions.act_window.view">
		<field eval="1" name="sequence"/>
		<field name="view_mode">tree</field>
		<field name="view_id" ref="searching_product_product_tree_view"/>
		<field name="act_window_id" ref="searching_product_variant_action"/>
	</record>

	<record id="action_searching_product_normal_form_view" model="ir.actions.act_window.view">
		<field eval="2" name="sequence"/>
		<field name="view_mode">form</field>
		<field name="view_id" ref="searching_product_normal_form_view"/>
		<field name="act_window_id" ref="searching_product_variant_action"/>
	</record>
	
	<record id="action_searching_product_kanban_view" model="ir.actions.act_window.view">
		<field eval="3" name="sequence"/>
		<field name="view_mode">kanban</field>
		<field name="view_id" ref="searching_product_kanban_view"/>
		<field name="act_window_id" ref="searching_product_variant_action"/>
	</record>
	
	<record id="searching_product_template_kanban_view" model="ir.ui.view">
        <field name="name">searching.product.template.product.kanban</field>
        <field name="model">product.template</field>
        <field name="arch" type="xml">
            <kanban create="0" edit="0">
                <field name="image_small"/>
                <field name="lst_price"/>
                <field name="type"/>
                <field name="is_product_variant"/>
                <field name="product_variant_count"/>
                <field name="product_variant_ids"/>
                <templates>
                    <t t-name="kanban-box">
                        <div class="oe_kanban_vignette oe_semantic_html_override">
                            <a type="open"><img t-att-src="kanban_image('product.template', 'image_small', record.id.value)" class="oe_kanban_image"/></a>
                            <div class="oe_kanban_details">
                                <h4>
                                    <a type="open">
                                         <span t-if="record.default_code.value">
                                             [<field name="default_code"/>]
                                          </span>
                                         <field name="name"/> 
                                    </a>
                                </h4>
                                <a name="%(searching_product_variant_action)d" type="action">
                                    <t t-esc="record.product_variant_count.value"/> Variants
                                </a>
                                <div name="tags"/>
                                <ul>
                                    <li>Price: <field name="lst_price"></field></li>
                                   	<li t-if="record.type.raw_value != 'service'">On hand: <field name="qty_available"/> <field name="uom_id"/></li>
                    				<li t-if="record.type.raw_value != 'service'">Forecasted: <field name="virtual_available"/> <field name="uom_id"/></li>
                                </ul>
                            </div>
                        </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>

    <record id="searching_product_template_action" model="ir.actions.act_window">
        <field name="name">Products</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">product.template</field>
        <field name="view_mode">kanban,tree,form</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="searching_product_template_kanban_view"/>
        <field name="context">{"search_default_filter_to_sell":1}</field>
    </record>
	
	<record id="action_searching_product_template_kanban_view" model="ir.actions.act_window.view">
		<field eval="1" name="sequence"/>
		<field name="view_mode">kanban</field>
		<field name="view_id" ref="searching_product_template_kanban_view"/>
		<field name="act_window_id" ref="searching_product_template_action"/>
	</record>
	
	<record id="action_searching_product_template_tree" model="ir.actions.act_window.view">
		<field eval="2" name="sequence"/>
		<field name="view_mode">tree</field>
		<field name="view_id" ref="searching_product_template_tree"/>
		<field name="act_window_id" ref="searching_product_template_action"/>
	</record>

	<record id="action_searching_product_template_form_view" model="ir.actions.act_window.view">
		<field eval="3" name="sequence"/>
		<field name="view_mode">form</field>
		<field name="view_id" ref="searching_product_template_form_view"/>
		<field name="act_window_id" ref="searching_product_template_action"/>
	</record>
	
    <menuitem action="searching_product_template_action"
        id="menu_searching_product_template_action"
        parent="menu_searching" sequence="1" />
	     
</data>
</openerp>
